package top.kaoshanji.p3ch26a;

import java.io.File;
import java.io.FilenameFilter;
import java.util.Arrays;
import java.util.Comparator;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * 代码清单-p3ch26a-629页a：通过接口传递代码
 * author kaoshanji
 * ^_^
 * create time 2025/3/4 10:49
 */
public class AnonymousDemo {

    public static void main(String[] args) {

        // 列出当前目录下的所有扩展名为 .txt 的文件
        File file = new File(".");
        File[] files = file.listFiles(new FilenameFilter() {

            @Override
            public boolean accept(File dir, String name) {
                if (name.endsWith(".txt")) {
                    return true;
                }
                return false;
            }
        });

        // 将 files 按照文件名排序
        Arrays.sort(files, new Comparator<File>() {
            @Override
            public int compare(File o1, File o2) {
                return o1.getName().compareTo(o2.getName());
            }
        });

        // 提交一个最简单的任务
        ExecutorService executor = Executors.newFixedThreadPool(100);
        executor.submit(new Runnable() {
            @Override
            public void run() {
                System.out.println("hello world");
            }
        });



    }



}
